<!-- Prefs -->
<?php if ($this->Membership_model->is_owner($bricabox->id)): ?>
<div class="block_header">
	<div id="block_prefs_<?php echo $inst->id; ?>" style="display: none;">
		<form action="/bricabox/<?php echo $bricabox->id; ?>/save_featured_block" method="post">
			<input type="hidden" name="id" value="<?php echo $inst->id; ?>" />
			<input type="hidden" name="return_to" value="/<?php echo $this->uri->uri_string(); ?>" />
			<fieldset>
				<h3>What should appear in this block?</h3>
				<div>
					
					<!-- Superbar -->
					Show
					<select class="superbar_field" name="entry_type">
						<option value="all">everything</option>
						<?php
						if ($content_types):
							foreach ($content_types->result() as $type):
						?>
						<option<?php if (@$name = str_replace('_', ' ', $parts['entry_type']) == $type->name) echo ' selected="selected"'; ?> value="<?php echo $type->name; ?>">just <?php echo strtolower(Inflect::pluralize($type->name)); ?></option>
						<?php
							endforeach;
						endif;
						?>
					</select>

					<?php if ($this->bricabox->bricabox_has_block($bricabox->id, 'tags')): ?>
					tagged
					<input type="text" class="superbar_field" size="15" name="tagged" value="<?php echo str_replace('_', ' ', str_replace(':', ',', @$parts['tagged'])); ?>" />
					<?php endif; ?>

					<?php if ($this->bricabox->bricabox_has_block($bricabox->id, 'categories')): ?>
					categorized
					<select class="superbar_field" name="categorized">
						<option value="-1"<?php if (!isset($parts['categorized']) || $parts['categorized'] == '-1') echo ' selected="selected"'; ?>>with anything</option>
						<?php
						if ($ctgys):
							foreach ($ctgys->result() as $ctgy):
						?>
						<option value="<?php echo $ctgy->id; ?>"<?php if (@$parts['categorized'] == $ctgy->id) echo ' selected="selected"'; ?>><?php echo $ctgy->name; ?></option>
						<?php
							endforeach;
						endif;
						?>
					</select>
					<?php endif; ?>

					sorted
					<select class="superbar_field" name="sort">
						<option<?php if (@$parts['sort'] == 'date_desc') echo ' selected="selected"'; ?> value="date_desc">newest first</option>
						<option<?php if (@$parts['sort'] == 'date_asc')  echo ' selected="selected"'; ?> value="date_asc">oldest first</option>
						<option<?php if (@$parts['sort'] == 'title_az')  echo ' selected="selected"'; ?> value="title_az">title A-Z</option>
						<option<?php if (@$parts['sort'] == 'title_za')  echo ' selected="selected"'; ?> value="title_za">title Z-A</option>
						<option<?php if (@$parts['sort'] == 'eng_desc')  echo ' selected="selected"'; ?> value="eng_desc">most popular first</option>
						<option<?php if (@$parts['sort'] == 'eng_asc') 	 echo ' selected="selected"'; ?> value="eng_asc">least popular first</option>
						<option<?php if (@$parts['sort'] == 'up') 	 	 echo ' selected="selected"'; ?> value="up">date, upcoming</option>
						<option<?php if (@$parts['sort'] == 'dt_desc') 	 echo ' selected="selected"'; ?> value="dt_desc">more recent first</option>
						<option<?php if (@$parts['sort'] == 'dt_asc') 	 echo ' selected="selected"'; ?> value="dt_asc">less recent first</option>
					</select>
	
				</div>
				
				<div>
					<label>How many entries would you like listed?</label><br />
					<input type="text" value="<?php echo @$parts['limit']; ?>" name="limit" size="5" />
				</div>
				
				<div class="controls">
					<input type="submit" value="Save" />
					or <a href="#" onclick="return PrefPane.toggle(<?php echo $inst->id; ?>);">cancel</a>
				</div>
			</fieldset>
		</form>
	</div>
</div>
<?php endif; ?>


<?php if (count($entries)): ?>
<ul>
<?php foreach ($entries as $i => $rel_entry): ?>
	<li><span class="number"><?php echo ($i+1); ?>.</span> <a href="/content/<?php echo $rel_entry['id']; ?>/<?php echo url_title($rel_entry->title); ?>"><?php echo $rel_entry->title; ?></a>
		<?php if ($BBX['bricabox']->engagement_type == 'button'): ?>&mdash; <?php echo $rel_entry->engagements.' '.$rel_entry->engagements['caption']; ?><?php endif; ?></li>
<?php endforeach; ?>
	<li class="last_child">
		<a style="border:none;vertical-align:middle;" href="<?php echo $rss_url ? $rss_url : '/entries/as/rss'; ?><?php echo rss_token(); ?>">
			<img src="/assets/images/rss.png" alt="RSS" /></a>
		<a href="/entries">See all entries</a>
		or <a href="#new_entry" onclick="Entry.showNewPanel();">Add something new</a>
	</li>
</ul>
<?php else: ?>
<h2>No entries found.</h2>
<?php endif; ?>